<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>demo</title>
    <!-- <script src="https://unpkg.com/vue@next"></script> -->
    <script src="https://unpkg.com/vue@3.0.5/dist/vue.global.js"></script>
  </head>

  <body>
    <div id="app"></div>
    <script>
      const app = Vue.createApp({
        data() {
          return {
            a: 1,
            count1: 10,
            count2: 21,
          };
        },
        //方法
        methods: {
          add() {
            this.a++;
          },
        },
        //计算属性
        computed: {
          total() {
            return Number(this.count1) + Number(this.count2);
          },
        },
        //监听器
        watch: {
          count2(current, prev) {
            console.log("当前", current, "上次值", prev);
          },
        },
        template: `
          <div>
            <div v-if='a==1'>一</div>
            <div v-else-if='a==2'>二</div>
            <div v-else>大于等于3</div>
            <button @click='add'>+1</button>
            <hr/>
            计算：
            <input type='text' v-model='count1' /> + 
            <input type='text' v-model='count2' />
            = {{total}}<br>
          </div>
        `,
      });

      const vm = app.mount("#app");
    </script>
  </body>
</html>
